package com.sunny.design.proxy.staticproxy;

import com.sunny.design.proxy.staticproxy.exam1.Father;
import com.sunny.design.proxy.staticproxy.exam1.Son;
import com.sunny.design.proxy.IOrderService;
import com.sunny.design.proxy.Order;
import com.sunny.design.proxy.OrderService;
import com.sunny.design.proxy.staticproxy.exam2.OrderServiceStaticProxy;

import java.util.Date;

/**
 * @author Sunny
 * @date 2020/1/1 16:55
 */
public class StaticProxyTest {
    public static void main(String[] args) {
        exam1Test();
        System.out.println("-----------------------------------");
        exam2Test();
    }

    public static void exam1Test() {
        Father father = new Father(new Son());
        father.findLove();
    }

    public static void exam2Test() {
        try {
            Order order = new Order();
             Date today = new Date();
             order.setCreateTime(today.getTime());
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
//            Date date = sdf.parse("2018/01/01");
//            order.setCreateTime(date.getTime());
            IOrderService orderService = new OrderServiceStaticProxy(new OrderService());
            orderService.createOrder(order);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
